'use strict';

angular.module('myApp.competition_add', [])

.controller('competition_addCtrl', ['$scope','$http',
	function($scope,$http){
    $scope.submit = function(competition){
 		competition.is_published = 0;
        $scope.tem = angular.copy(competition);
        console.log( $scope.tem);
        $http.post('v1/competition',$scope.tem).success(function(data){
            if( !data.error ){
                alert("新增成功","success");
                window.location.href = '#/competition_new';
            }else{
                alert(data.message);
            }
        });
    }
    // 日历
    $('.form-date').datetimepicker(
    {
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
        format: 'yyyy-mm-dd'
    });
    $('.form-datetime').datetimepicker(
    {
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'yyyy-mm-dd hh:ii'
    });
}]);